package com.atguigu.zy.interview.jvm.gc;

import java.util.Random;

/**
 * @author Jungle
 * @create 2022-09-05 9:06
 *      查看垃圾回收器：java -XX:+PrintCommandLineFlags -version
 * @formatter:off
 * 新生和老年代，无论配置哪一个都会匹配相应的GC算法
 * 新生代配置：
 * 1
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseSerialGC      (DefNew+Tenured)
 * 2
 *  -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParNewGC    ( ParNew+Tenured)
     * 备注情况:Java Hotspot(TM)64-Bit server V warning:
     * using the ParNew young collector with the serial old collector is deprecatedand
     * will likely be removed in a future release
 * 3
 * -Xms10m -Xmx12m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParallelGC   (PSYoungGen+ParOldGen)
 *
 * 老年代配置：
 * 4
     * 4.1
     * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParallelOldGC    ( PSYoungGen+ParOldGen)
     * 4.2不加就是默认UseParallelGC
     * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags    ( PSYoungGen+ParOLdGen)
 *
 * 5
 * -Xms10m -Xmx20m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseConcMarkSweepGC   (parnewgeneration+ concurrenMarkSweep)
 * 6
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseG1GC
 *                                                              后面单独讲解G1
 * 7（理论知道即可，实际中己经被优化掉了，没有了。会报不能识别)
 * -Xms12m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseSerialOldGC   (Parallel Scavenge + Serial Old )
 * -
 * 下面是故意繁琐配置，主要是为了学习，一般生产不这么配'置:
 * 下面是故意繁琐配置，主要是为了学习，一殷生产不这么配置:
 * 下面是故意繁琐配置，主要是为了学习，一殷生产不这么配'置:  新生和老年只用配置一个，互相关联
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParallelGC -XX:+UseParallelOldGC      (PSYoungcGen+ParOldGen)
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParNewGC -XX:+UseConcMarkSweepGC (par new generation + concurrent mark-sweep generation)
 * @formatter:on
 */
public class GcDemo {
    public static void main(String[] args) {
        System.out.println("GCDemo hello");
        String str = "atguigu";
        try {
            while (true) {
                str += str + new Random().nextInt(77777777) + new Random().nextInt(88888888);
                //加入常量池返回
                str.intern();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
